Working fine here, but I decided to implement it only for 26.2+ because the API versions before that were not as reliable.
Remember to first request authorization like this:
func requestAuthorization() async -> (granted: Bool, status: String) {
do {
let state = try await AlarmManager.shared.requestAuthorization()
let stateString: String
switch state {
case .authorized: stateString = "Authorized"
case .denied: stateString = "Denied"
case .notDetermined: stateString = "Not Determined"
@unknown default: stateString = "Unknown"
}
let granted = state == .authorized
print("[AlarmKit] Authorization state: (stateString)")
return (granted, stateString)
} catch {
print("[AlarmKit] Authorization error: (error)")
return (false, "Error")
}
}